Crate wat

Source
Expand description

A Rust parser for the WebAssembly Text format

This crate contains a stable interface to the parser for the WAT format of WebAssembly text files. The format parsed by this crate follows the online specification.

§Examples

Parse an in-memory string:

let wat = r#"
    (module
        (func $foo)

        (func (export "bar")
            call $foo
        )
    )
"#;

let binary = wat::parse_str(wat)?;
// ...

Parse an on-disk file:

let binary = wat::parse_file("./foo.wat")?;
// ...

§Evolution of the WAT Format

WebAssembly, and the WAT format, are an evolving specification. Features are added to WAT, WAT changes, and sometimes WAT breaks. The policy of this crate is that it will always follow the official specification for WAT files.

Future WebAssembly features will be accepted to this parser and they will not require a feature gate to opt-in. All implemented WebAssembly features will be enabled at all times. Using a future WebAssembly feature in the WAT format may cause breakage because while specifications are in development the WAT syntax (and/or binary encoding) will often change. This crate will do its best to keep up with these proposals, but breaking textual changes will be published as non-breaking semver changes to this crate.

§Stability

This crate is intended to be a very stable shim over the wast crate which is expected to be much more unstable. The wast crate contains AST data structures for parsing *.wat files and they will evolve was the WAT and WebAssembly specifications evolve over time.

This crate is currently at version 1.x.y, and it is intended that it will remain here for quite some time. Breaking changes to the WAT format will be landed as a non-semver-breaking version change in this crate. This crate will always follow the official specification for WAT.

Structs§

  • Errors from this crate related to parsing WAT files
  • Parser configuration for transforming bytes into WebAssembly binaries.

Enums§

Functions§

Type Aliases§

  • A convenience type definition for Result where the error is Error